package com.minsf.example.consumer;

import com.minsf.example.common.model.User;
import com.minsf.example.common.service.UserService;
import com.minsf.rpc.RpcApplication;
import com.minsf.rpc.bootstrap.ConsumerBootstrap;
import com.minsf.rpc.config.RpcConfig;
import com.minsf.rpc.proxy.ServiceProxyFactory;
import com.minsf.rpc.utils.ConfigUtils;

/**
 * @Description
 * @Author minify
 * @Date 2024/3/16 0:31
 * @Project sf-rpc
 */
public class EasyConsumerExample {

    public static void main(String[] args) {
        // RPC 框架初始化
        ConsumerBootstrap.init();

        User user = new User();
        user.setName("minsf");

        System.out.println("消费端");

        UserService proxy = ServiceProxyFactory.getProxy(UserService.class);
        User serviceUser = proxy.getUser(user);
        if (serviceUser != null) {
            System.out.println(serviceUser);
        } else {
            System.out.println("user = null");
        }
        System.out.println("getMock() = " + RpcApplication.getRpcConfig().getMock());
        System.out.println("proxy.getNumber() = " + proxy.getNumber());
//        RpcConfig rpc = ConfigUtils.localConfig(RpcConfig.class, "rpc");
//        System.out.println(rpc);

        System.out.println("proxy.getList() = " + proxy.getList());

        System.out.println("proxy.getUser(user) = " + proxy.getUser(user));
    }
}
